<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>axios创建实例对象</title>
    <script crossorigin="anonymous" src="https://cdn.bootcss.com/axios/0.19.2/axios.min.js"></script>
</head>
<body>
    <script>
        // axios({
        //     method:'GET',
        //     url:'http://a.com/server'
        // })
        // axios({
        //     method:'GET',
        //     url:'http://a.com/goods'
        // })
        // axios({
        //     method:'GET',
        //     url:'http://a.com/users'
        // })

        // axios({
        //     method:'POST',
        //     url:'http://b.com/users'
        // })
        // axios({
        //     method:'POST',
        //     url:'http://b.com/goods'
        // })
        // axios({
        //     method:'POST',
        //     url:'http://b.com/orders'
        // })

        // 通过创建实例的方式，管理不同域名下的接口
        let tianqi = axios.create({
            method:'get',
            baseURL:'https://v0.yiketianqi.com',
            timeout: 3000
        })
        // 配置天气接口对象
        tianqi({
            url:'/api?unescape=1&version=v91&appid=43656176&appsecret=I42og6Lm&ext=&cityid=&city=北京'
        }).then(response=>{
            console.log(response);
        })
        // 配置 zyx 接口对象
        let zyx = axios.create({
            baseURL:'http://zyx.com:8080',
            params:{a:1,b:2},
            headers:{z:200,y:100},
            timeout:2000
        });

        zyx.get('/server').then(response=>{
            console.log(response);
        })

    </script>
</body>
</html>